home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1994-09-23 | 2.8 KB | [TEXT/MPCC] |
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary).
You can browse this item here: day.c
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [MPCC] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 05 64 61 79 2e 63 00 | 00 00 00 00 00 00 00 00 |..day.c.|........|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 43 | 43 00 00 00 00 00 00 00 |.TEXTMPC|C.......|
|00000050| 00 00 00 00 00 08 41 00 | 00 01 9a aa a8 d2 32 aa |......A.|......2.|
|00000060| a8 d2 32 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..2.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 f0 8c 00 00 |........|........|
|00000080| 2f 2a 0d 20 2a 20 64 61 | 79 2e 63 0d 20 2a 0d 20 |/*. * da|y.c. *. |
|00000090| 2a 20 4d 61 69 6e 20 66 | 69 6c 65 20 66 6f 72 20 |* Main f|ile for |
|000000a0| 6d 61 63 69 6e 74 6f 73 | 68 20 64 61 79 20 63 6c |macintos|h day cl|
|000000b0| 69 65 6e 74 2e 20 74 6f | 20 72 75 6e 20 77 69 74 |ient. to| run wit|
|000000c0| 68 20 6d 79 20 6d 6f 64 | 69 66 69 65 64 20 64 61 |h my mod|ified da|
|000000d0| 79 64 20 64 61 65 6d 6f | 6e 2e 0d 20 2a 0d 20 2a |yd daemo|n.. *. *|
|000000e0| 20 4d 69 6b 65 20 54 72 | 65 6e 74 20 38 2f 39 34 | Mike Tr|ent 8/94|
|000000f0| 0d 20 2a 0d 20 2a 2f 0d | 0d 2f 2a 20 4d 61 69 6e |. *. */.|./* Main|
|00000100| 20 4d 61 63 20 49 6e 63 | 6c 75 64 65 73 20 2a 2f | Mac Inc|ludes */|
|00000110| 0d 23 69 6e 63 6c 75 64 | 65 20 3c 54 79 70 65 73 |.#includ|e <Types|
|00000120| 2e 68 3e 0d 23 69 6e 63 | 6c 75 64 65 20 3c 4d 65 |.h>.#inc|lude <Me|
|00000130| 6d 6f 72 79 2e 68 3e 0d | 23 69 6e 63 6c 75 64 65 |mory.h>.|#include|
|00000140| 20 3c 51 75 69 63 6b 64 | 72 61 77 2e 68 3e 0d 23 | <Quickd|raw.h>.#|
|00000150| 69 6e 63 6c 75 64 65 20 | 3c 46 6f 6e 74 73 2e 68 |include |<Fonts.h|
|00000160| 3e 0d 23 69 6e 63 6c 75 | 64 65 20 3c 45 76 65 6e |>.#inclu|de <Even|
|00000170| 74 73 2e 68 3e 0d 23 69 | 6e 63 6c 75 64 65 20 3c |ts.h>.#i|nclude <|
|00000180| 4d 65 6e 75 73 2e 68 3e | 0d 23 69 6e 63 6c 75 64 |Menus.h>|.#includ|
|00000190| 65 20 3c 57 69 6e 64 6f | 77 73 2e 68 3e 0d 23 69 |e <Windo|ws.h>.#i|
|000001a0| 6e 63 6c 75 64 65 20 3c | 54 65 78 74 45 64 69 74 |nclude <|TextEdit|
|000001b0| 2e 68 3e 0d 23 69 6e 63 | 6c 75 64 65 20 3c 44 69 |.h>.#inc|lude <Di|
|000001c0| 61 6c 6f 67 73 2e 68 3e | 0d 23 69 6e 63 6c 75 64 |alogs.h>|.#includ|
|000001d0| 65 20 3c 4f 53 55 74 69 | 6c 73 2e 68 3e 0d 23 69 |e <OSUti|ls.h>.#i|
|000001e0| 6e 63 6c 75 64 65 20 3c | 54 6f 6f 6c 55 74 69 6c |nclude <|ToolUtil|
|000001f0| 73 2e 68 3e 0d 23 69 6e | 63 6c 75 64 65 20 3c 53 |s.h>.#in|clude <S|
|00000200| 65 67 4c 6f 61 64 2e 68 | 3e 0d 0d 2f 2a 20 41 64 |egLoad.h|>../* Ad|
|00000210| 64 69 74 69 6f 6e 61 6c | 20 4d 61 63 20 49 6e 63 |ditional| Mac Inc|
|00000220| 6c 75 64 65 73 20 2a 2f | 0d 23 69 6e 63 6c 75 64 |ludes */|.#includ|
|00000230| 65 20 3c 4d 61 63 54 43 | 50 43 6f 6d 6d 6f 6e 54 |e <MacTC|PCommonT|
|00000240| 79 70 65 73 2e 68 3e 20 | 2f 2f 66 6f 72 20 69 70 |ypes.h> |//for ip|
|00000250| 2e 68 0d 0d 2f 2a 20 41 | 6e 73 69 20 49 6e 63 6c |.h../* A|nsi Incl|
|00000260| 75 64 65 73 20 2a 2f 0d | 23 69 6e 63 6c 75 64 65 |udes */.|#include|
|00000270| 20 3c 73 74 64 69 6f 2e | 68 3e 0d 0d 2f 2a 20 41 | <stdio.|h>../* A|
|00000280| 64 64 69 74 69 6f 6e 61 | 6c 20 49 6e 63 6c 75 64 |dditiona|l Includ|
|00000290| 65 73 20 2a 2f 0d 23 64 | 65 66 69 6e 65 20 4d 41 |es */.#d|efine MA|
|000002a0| 49 4e 0d 23 69 6e 63 6c | 75 64 65 20 22 67 6c 6f |IN.#incl|ude "glo|
|000002b0| 62 61 6c 73 2e 68 22 0d | 23 69 6e 63 6c 75 64 65 |bals.h".|#include|
|000002c0| 20 22 69 70 2e 68 22 0d | 0d 76 6f 69 64 20 49 6e | "ip.h".|.void In|
|000002d0| 69 74 54 6f 6f 6c 42 6f | 78 28 76 6f 69 64 29 3b |itToolBo|x(void);|
|000002e0| 0d 76 6f 69 64 20 67 65 | 74 5f 64 61 74 61 28 63 |.void ge|t_data(c|
|000002f0| 68 61 72 20 2a 73 74 72 | 29 3b 0d 0d 6d 61 69 6e |har *str|);..main|
|00000300| 28 29 0d 7b 0d 09 57 69 | 6e 64 6f 77 50 74 72 20 |().{..Wi|ndowPtr |
|00000310| 77 3b 0d 09 52 65 63 74 | 09 20 77 69 6e 64 52 65 |w;..Rect|. windRe|
|00000320| 63 74 3b 0d 09 63 68 61 | 72 20 73 5b 31 30 30 5d |ct;..cha|r s[100]|
|00000330| 3b 0d 0d 09 49 6e 69 74 | 54 6f 6f 6c 42 6f 78 28 |;...Init|ToolBox(|
|00000340| 29 3b 0d 09 0d 09 53 65 | 74 52 65 63 74 28 26 77 |);....Se|tRect(&w|
|00000350| 69 6e 64 52 65 63 74 2c | 20 34 30 2c 34 30 2c 33 |indRect,| 40,40,3|
|00000360| 30 30 2c 31 35 30 29 3b | 0d 09 69 66 20 28 20 28 |00,150);|..if ( (|
|00000370| 77 20 3d 20 4e 65 77 57 | 69 6e 64 6f 77 20 28 6e |w = NewW|indow (n|
|00000380| 69 6c 2c 20 26 77 69 6e | 64 52 65 63 74 2c 20 22 |il, &win|dRect, "|
|00000390| 5c 70 44 61 74 65 22 2c | 20 74 72 75 65 2c 20 64 |\pDate",| true, d|
|000003a0| 6f 63 75 6d 65 6e 74 50 | 72 6f 63 2c 20 28 57 69 |ocumentP|roc, (Wi|
|000003b0| 6e 64 6f 77 50 74 72 29 | 20 2d 31 2c 20 66 61 6c |ndowPtr)| -1, fal|
|000003c0| 73 65 2c 20 30 29 29 20 | 3d 3d 20 6e 69 6c 29 20 |se, 0)) |== nil) |
|000003d0| 7b 0d 09 09 53 79 73 42 | 65 65 70 28 33 29 3b 0d |{...SysB|eep(3);.|
|000003e0| 09 09 72 65 74 75 72 6e | 3b 0d 09 7d 20 0d 09 53 |..return|;..} ..S|
|000003f0| 65 74 50 6f 72 74 28 77 | 29 3b 0d 09 0d 09 4d 6f |etPort(w|);....Mo|
|00000400| 76 65 54 6f 28 31 30 2c | 31 35 29 3b 0d 09 44 72 |veTo(10,|15);..Dr|
|00000410| 61 77 53 74 72 69 6e 67 | 28 22 5c 70 44 61 79 20 |awString|("\pDay |
|00000420| 43 6c 69 65 6e 74 3a 20 | 70 6f 72 74 20 31 30 32 |Client: |port 102|
|00000430| 36 22 29 3b 0d 09 0d 09 | 67 65 74 5f 64 61 74 61 |6");....|get_data|
|00000440| 28 73 29 3b 0d 09 0d 09 | 4d 6f 76 65 54 6f 28 31 |(s);....|MoveTo(1|
|00000450| 30 2c 33 30 29 3b 0d 09 | 44 72 61 77 53 74 72 69 |0,30);..|DrawStri|
|00000460| 6e 67 28 28 43 6f 6e 73 | 74 53 74 72 32 35 35 50 |ng((Cons|tStr255P|
|00000470| 61 72 61 6d 29 73 29 3b | 0d 09 0d 09 77 68 69 6c |aram)s);|....whil|
|00000480| 65 20 28 21 42 75 74 74 | 6f 6e 28 29 29 3b 0d 09 |e (!Butt|on());..|
|00000490| 0d 09 43 6c 6f 73 65 57 | 69 6e 64 6f 77 28 77 29 |..CloseW|indow(w)|
|000004a0| 3b 0d 7d 0d 09 0d 09 0d | 76 6f 69 64 20 49 6e 69 |;.}.....|void Ini|
|000004b0| 74 54 6f 6f 6c 42 6f 78 | 28 76 6f 69 64 29 0d 7b |tToolBox|(void).{|
|000004c0| 0d 09 49 6e 69 74 47 72 | 61 66 28 26 71 64 2e 74 |..InitGr|af(&qd.t|
|000004d0| 68 65 50 6f 72 74 29 3b | 0d 09 49 6e 69 74 46 6f |hePort);|..InitFo|
|000004e0| 6e 74 73 28 29 3b 0d 09 | 49 6e 69 74 57 69 6e 64 |nts();..|InitWind|
|000004f0| 6f 77 73 28 29 3b 0d 09 | 49 6e 69 74 4d 65 6e 75 |ows();..|InitMenu|
|00000500| 73 28 29 3b 0d 09 54 45 | 49 6e 69 74 28 29 3b 0d |s();..TE|Init();.|
|00000510| 09 49 6e 69 74 44 69 61 | 6c 6f 67 73 28 6e 69 6c |.InitDia|logs(nil|
|00000520| 29 3b 0d 09 49 6e 69 74 | 43 75 72 73 6f 72 28 29 |);..Init|Cursor()|
|00000530| 3b 0d 09 0d 09 69 66 20 | 28 49 6e 69 74 4d 61 63 |;....if |(InitMac|
|00000540| 54 43 50 28 29 20 21 3d | 20 6e 6f 45 72 72 29 20 |TCP() !=| noErr) |
|00000550| 7b 0d 09 09 53 79 73 42 | 65 65 70 28 33 29 3b 0d |{...SysB|eep(3);.|
|00000560| 09 09 45 78 69 74 54 6f | 53 68 65 6c 6c 28 29 3b |..ExitTo|Shell();|
|00000570| 0d 09 7d 0d 7d 0d 0d 76 | 6f 69 64 20 67 65 74 5f |..}.}..v|oid get_|
|00000580| 64 61 74 61 28 63 68 61 | 72 20 2a 73 74 72 29 0d |data(cha|r *str).|
|00000590| 7b 0d 09 69 6e 74 20 73 | 2c 20 65 72 72 2c 20 6e |{..int s|, err, n|
|000005a0| 3d 20 31 2c 20 74 6f 74 | 20 3d 20 30 3b 0d 09 73 |= 1, tot| = 0;..s|
|000005b0| 74 72 75 63 74 20 73 6f | 63 6b 61 64 64 72 5f 69 |truct so|ckaddr_i|
|000005c0| 6e 20 73 61 3b 0d 09 0d | 09 73 20 3d 20 73 6f 63 |n sa;...|.s = soc|
|000005d0| 6b 65 74 28 49 50 50 52 | 4f 54 4f 5f 54 43 50 29 |ket(IPPR|OTO_TCP)|
|000005e0| 3b 0d 09 69 66 20 28 73 | 20 3c 20 30 29 20 7b 0d |;..if (s| < 0) {.|
|000005f0| 09 09 73 70 72 69 6e 74 | 66 28 73 74 72 2c 20 28 |..sprint|f(str, (|
|00000600| 63 6f 6e 73 74 20 63 68 | 61 72 20 2a 29 22 5c 70 |const ch|ar *)"\p|
|00000610| 73 6f 63 6b 65 74 28 29 | 20 65 25 64 2c 20 6d 25 |socket()| e%d, m%|
|00000620| 64 22 2c 20 67 45 72 72 | 6e 6f 2c 20 67 4d 61 63 |d", gErr|no, gMac|
|00000630| 45 72 72 6e 6f 29 3b 0d | 09 09 72 65 74 75 72 6e |Errno);.|..return|
|00000640| 3b 0d 09 7d 0d 09 0d 09 | 73 61 2e 73 69 6e 5f 70 |;..}....|sa.sin_p|
|00000650| 6f 72 74 20 3d 20 31 30 | 32 36 3b 0d 09 73 61 2e |ort = 10|26;..sa.|
|00000660| 73 69 6e 5f 61 64 64 72 | 20 3d 20 47 65 74 48 6f |sin_addr| = GetHo|
|00000670| 73 74 42 79 4e 61 6d 65 | 28 22 31 34 34 2e 38 39 |stByName|("144.89|
|00000680| 2e 34 30 2e 36 22 29 3b | 0d 09 2f 2f 73 61 2e 73 |.40.6");|..//sa.s|
|00000690| 69 6e 5f 61 64 64 72 20 | 3d 20 30 78 39 30 35 39 |in_addr |= 0x9059|
|000006a0| 32 38 36 36 3b 0d 09 69 | 66 20 28 73 61 2e 73 69 |2866;..i|f (sa.si|
|000006b0| 6e 5f 61 64 64 72 20 3d | 3d 20 30 29 20 7b 0d 09 |n_addr =|= 0) {..|
|000006c0| 09 73 70 72 69 6e 74 66 | 28 73 74 72 2c 20 28 63 |.sprintf|(str, (c|
|000006d0| 6f 6e 73 74 20 63 68 61 | 72 20 2a 29 22 5c 70 47 |onst cha|r *)"\pG|
|000006e0| 65 74 48 6f 73 74 42 79 | 4e 61 6d 65 28 29 20 65 |etHostBy|Name() e|
|000006f0| 25 64 2c 20 6d 25 64 22 | 2c 20 67 45 72 72 6e 6f |%d, m%d"|, gErrno|
|00000700| 2c 20 67 4d 61 63 45 72 | 72 6e 6f 29 3b 0d 09 09 |, gMacEr|rno);...|
|00000710| 72 65 74 75 72 6e 3b 0d | 09 7d 09 0d 09 0d 09 69 |return;.|.}.....i|
|00000720| 66 20 28 28 65 72 72 20 | 3d 20 63 6f 6e 6e 65 63 |f ((err |= connec|
|00000730| 74 28 73 2c 26 73 61 29 | 29 20 21 3d 20 6e 6f 45 |t(s,&sa)|) != noE|
|00000740| 72 72 29 20 7b 0d 09 09 | 73 70 72 69 6e 74 66 28 |rr) {...|sprintf(|
|00000750| 73 74 72 2c 20 28 63 6f | 6e 73 74 20 63 68 61 72 |str, (co|nst char|
|00000760| 20 2a 29 22 5c 70 63 6f | 6e 6e 65 63 74 20 65 72 | *)"\pco|nnect er|
|00000770| 72 6f 72 22 29 3b 0d 09 | 09 72 65 74 75 72 6e 3b |ror");..|.return;|
|00000780| 0d 09 7d 0d 09 09 0d 09 | 77 68 69 6c 65 20 28 28 |..}.....|while ((|
|00000790| 6e 3d 6d 61 63 5f 72 65 | 61 64 28 73 2c 20 73 74 |n=mac_re|ad(s, st|
|000007a0| 72 2c 20 31 30 30 29 29 | 20 3e 20 30 29 20 7b 0d |r, 100))| > 0) {.|
|000007b0| 09 09 73 74 72 5b 6e 5d | 20 3d 20 27 5c 30 27 3b |..str[n]| = '\0';|
|000007c0| 0d 09 09 74 6f 74 20 2b | 3d 20 6e 3b 20 20 2f 2f |...tot +|= n; //|
|000007d0| 6b 65 65 70 20 61 20 72 | 75 6e 6e 69 6e 67 20 74 |keep a r|unning t|
|000007e0| 6f 74 61 6c 20 6f 66 20 | 6c 65 6e 67 74 68 20 6f |otal of |length o|
|000007f0| 66 20 62 79 74 65 73 20 | 72 65 63 65 69 76 65 64 |f bytes |received|
|00000800| 2e 0d 09 7d 09 0d 0d 09 | 66 6f 72 20 28 6e 3d 74 |...}....|for (n=t|
|00000810| 6f 74 2d 31 3b 20 6e 20 | 3e 3d 30 3b 20 6e 2d 2d |ot-1; n |>=0; n--|
|00000820| 29 20 7b 0d 09 09 73 74 | 72 5b 6e 2b 31 5d 20 3d |) {...st|r[n+1] =|
|00000830| 20 73 74 72 5b 6e 5d 3b | 0d 09 7d 0d 09 73 74 72 | str[n];|..}..str|
|00000840| 5b 30 5d 20 3d 20 74 6f | 74 2d 31 3b 0d 09 0d 09 |[0] = to|t-1;....|
|00000850| 69 66 20 28 6d 61 63 5f | 63 6c 6f 73 65 28 73 29 |if (mac_|close(s)|
|00000860| 29 20 7b 0d 09 09 2f 2f | 73 70 72 69 6e 74 66 28 |) {...//|sprintf(|
|00000870| 73 74 72 2c 20 28 63 6f | 6e 73 74 20 63 68 61 72 |str, (co|nst char|
|00000880| 20 2a 29 22 5c 70 63 6c | 6f 73 65 20 65 72 72 6f | *)"\pcl|ose erro|
|00000890| 72 28 29 20 65 25 64 2c | 20 6d 25 64 22 2c 20 67 |r() e%d,| m%d", g|
|000008a0| 45 72 72 6e 6f 2c 20 67 | 4d 61 63 45 72 72 6e 6f |Errno, g|MacErrno|
|000008b0| 29 3b 0d 09 09 72 65 74 | 75 72 6e 3b 0d 09 7d 0d |);...ret|urn;..}.|
|000008c0| 7d 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |}.......|........|
|000008d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000008e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000008f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000900| 00 00 01 00 00 00 01 54 | 00 00 00 54 00 00 00 46 |.......T|...T...F|
|00000910| 77 20 70 6f 73 69 74 69 | 6f 6e 73 00 00 00 30 00 |w positi|ons...0.|
|00000920| 3c 00 d8 00 4a 01 69 00 | 00 01 00 00 64 00 00 00 |<...J.i.|....d...|
|00000930| 05 64 61 79 2e 63 02 00 | 00 00 50 61 72 74 53 49 |.day.c..|..PartSI|
|00000940| 54 21 00 00 00 00 00 00 | 00 00 00 02 ab d6 00 00 |T!......|........|
|00000950| 00 00 50 61 72 74 53 49 | 54 21 00 00 00 00 00 00 |..PartSI|T!......|
|00000960| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000970| 00 00 ab f8 9c 96 00 00 | 00 00 00 00 01 9a 72 6f |........|......ro|
|00000980| 20 72 65 71 75 69 72 65 | 73 20 53 79 73 74 65 6d | require|s System|
|00000990| 20 34 2e 32 20 6f 72 20 | 6e 65 77 65 72 20 61 6e | 4.2 or |newer an|
|000009a0| 64 20 61 20 4d 61 63 69 | 6e 74 6f 73 68 20 35 31 |d a Maci|ntosh 51|
|000009b0| 32 4b 45 20 6f 72 20 6e | 65 77 65 72 37 54 68 65 |2KE or n|ewer7The|
|000009c0| 72 65 20 69 73 20 6e 6f | 74 20 65 6e 6f 75 67 68 |re is no|t enough|
|000009d0| 20 6d 65 6d 6f 72 79 20 | 61 76 61 69 6c 61 62 6c | memory |availabl|
|000009e0| 65 20 74 6f 20 72 75 6e | 20 43 6f 6d 70 61 63 74 |e to run| Compact|
|000009f0| 20 50 72 6f 4d 41 6e 20 | 75 6e 72 65 63 6f 76 65 | ProMAn |unrecove|
|00000a00| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 00 00 00 |...H..Mo|naco....|
|00000a10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000a20| 00 00 00 00 00 00 00 03 | 00 04 00 75 ff fa 01 e6 |........|...u....|
|00000a30| 02 6d 00 75 ff fa 01 e6 | 02 6d ab 64 72 a2 00 00 |.m.u....|.m.dr...|
|00000a40| 00 00 00 00 08 41 00 00 | 00 00 01 00 00 00 00 04 |.....A..|........|
|00000a50| 00 01 00 01 00 00 01 00 | 00 00 01 54 00 00 00 54 |........|...T...T|
|00000a60| 00 00 00 46 01 4d f9 48 | 11 a2 00 00 00 1c 00 46 |...F.M.H|.......F|
|00000a70| 00 01 4d 50 53 52 00 00 | 00 12 4d 57 42 42 00 00 |..MPSR..|..MWBB..|
|00000a80| 00 1e 03 ed ff ff 00 00 | 00 00 00 00 00 00 03 f0 |........|........|
|00000a90| ff ff 00 00 00 4c 00 00 | 00 00 00 00 00 00 00 00 |.....L..|........|
|00000aa0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000ab0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000ac0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000ad0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000ae0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000af0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+